package cn.itcast.goods.mapper;

import cn.itcast.goods.pojo.SetmealDish;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface SetmealDishMapper {

    /**
     * 新增套餐菜品关系
     * @param e
     */
    @Insert("insert into setmeal_dish(setmeal_id, dish_id, name, price, copies)" +
            " values(#{setmealId},#{dishId},#{name},#{price},#{copies})")
    void insert(SetmealDish e);

    /**
     * 根据套餐id批量删除
     * @param ids
     */
    void deleteBySetmealIds(@Param("ids") List<Long> ids);

    /**
     * 根据菜品id批量查询
     * @param dishIds
     * @return
     */
    List<SetmealDish> getByDishIds(List<Long> dishIds);

    /**
     *
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id = #{id}")
    List<SetmealDish> getBySetmealId(Long id);

    /**
     * 菜品信息更新时同时更新菜品套餐关系表中信息
     * @param dishId
     * @param name
     * @param price
     */
    void updateByDishIdWithNameAndPrice(Long dishId, String name, BigDecimal price);
}
